package cn.zhf.shop.controller;


import cn.zhf.shop.entity.Bankcard;
import cn.zhf.shop.entity.Message;
import cn.zhf.shop.service.BankcardService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/api/bankCard")
@Api(tags = "银行管理")
public class BankcardController {

    @Resource
    private BankcardService bankcardService;

    @PostMapping("/")
    @ApiOperation(value = "增加新的银行卡")
    public Message insert(Bankcard bankcard){

        return bankcardService.insertSelective(bankcard);
    }

    @GetMapping("/one")
    @ApiOperation(value = "根据银行卡id查询银行卡")
    public Message<Bankcard> selectByid(int id){
        return bankcardService.selectByPrimaryKey(id);
    }

    @GetMapping("/all")
    @ApiOperation(value = "根据userid查询所有的银行卡")
    public Message<List<Bankcard>> selectAllByUserid(String userid){
        return bankcardService.selectAllByClassUserId(userid);
    }

    @DeleteMapping("/")
    @ApiOperation(value = "根据银行卡id删除银行卡")
    public Message deleteById(int id){
        return bankcardService.deleteByPrimaryKey(id);
    }

    @PutMapping("/")
    @ApiOperation(value = "根据id修改银行卡信息")
    public Message update(Bankcard bankcard){
        return bankcardService.updateByPrimaryKeySelective(bankcard);
    }
}
